Skip to content

fix: use txMeta.actionId as a temporary key to capture data for non-STX where it fails before submission#7696

Merged
infiniteflower merged 14 commits intomainfrom
swaps-3591-provider-not-set
Jan 22, 2026
Merged

fix: use txMeta.actionId as a temporary key to capture data for non-STX where it fails before submission#7696
infiniteflower merged 14 commits intomainfrom
swaps-3591-provider-not-set

Conversation

@infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Jan 21, 2026

Explanation

This PR changes the way that BridgeStatusController's history items are keyed for non-STX to improve status tracking and addressing some gaps in analytics.

  1. Generate a custom actionId, key historyItem by actionId and add to state BEFORE submitting tx. Previously we would not even have a historyItem, if the the tx failed before being submitted on chain.
  2. Pass actionId to TransactionController.addTransaction() as a part of the request
  3. For txs that actually get submitted on chain, rekey their actionId to their txMeta.id
  4. On transactionFailed use txMeta.actionId to identify txs that failed before actually being submitted on chain and handle metrics

You can test this by using a Smart Account on Polygon and attempting to do a USDT > POL swap that requires an approval. You should see error In flight transaction limit reached for delegate accounts in the logs. When you check Mixpanel, the provider field should be properly filled out. A video of the whole process in in MetaMask/metamask-mobile#25010.

References

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591
Related to MetaMask/metamask-mobile#25010

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Improves robustness of transaction tracking and analytics around pre-submission failures.

  • Use actionId as a temporary history key for non-batch EVM submissions; store actionId in BridgeHistoryItem and rekey to txMeta.id after successful submission (updating txMetaId and srcTxHash)
  • On TransactionController:transactionFailed, look up history by txMeta.id then actionId to mark failed and track metrics; skip tracking for rejected status
  • Enforce bridgeTxMeta.id requirement in startPollingForBridgeTxStatus; exclude items without txMetaId from restart polling
  • Add getHistoryKey and getIntentFromQuote utils; make BridgeHistoryItem.txMetaId optional and StartPollingForBridgeTxStatusArgs.bridgeTxMeta optional; expand tests and snapshots accordingly

Written by Cursor Bugbot for commit 385b6d8. This will update automatically on new commits. Configure here.

@infiniteflower infiniteflower changed the title fix: use txMeta.actionId as a temporary key to capture tx where it fa… fix: use txMeta.actionId as a temporary key to capture tx where it fails before submission Jan 22, 2026
@infiniteflower infiniteflower changed the title fix: use txMeta.actionId as a temporary key to capture tx where it fails before submission fix: use txMeta.actionId as a temporary key to capture data for non-STX where it fails before submission Jan 22, 2026
@infiniteflower infiniteflower added the team-swaps-and-bridge Swaps and Bridge team label Jan 22, 2026
@infiniteflower infiniteflower force-pushed the swaps-3591-provider-not-set branch from ee23916 to ef54173 Compare January 22, 2026 19:31
Extract history key determination logic into a pure function to improve
test coverage. The function validates that either actionId or bridgeTxMetaId
is provided, throwing if neither is available.
Extract intent validation logic into a pure function to improve
test coverage. The function validates that intent data exists in
the quote response, throwing if missing.
@infiniteflower infiniteflower marked this pull request as ready for review January 22, 2026 20:11
@infiniteflower infiniteflower requested review from a team as code owners January 22, 2026 20:11
…istory

Since bridgeTxMeta is now optional, we don't need to pass an empty object
when adding pre-submission history. The actionId is used as the key instead.
@infiniteflower infiniteflower added this pull request to the merge queue Jan 22, 2026
Merged via the queue into main with commit 23e835c Jan 22, 2026
302 checks passed
@infiniteflower infiniteflower deleted the swaps-3591-provider-not-set branch January 22, 2026 20:59
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Jan 27, 2026
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR attempts to look up historyItems by `actionId` where possible in
order to set the `provider` field properly in analytics on failed txs.

It also fixes an issue where swaps were not being picked up properly on
the tx activity list. Also if you notice, there is no more flash of
`Swaps Transaction` anymore before turning into `Swap X to Y`, this is
because we now always have the `historyItem` data for non-STX txs.

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591

Related to MetaMask/core#7696

## **Manual testing steps**

```gherkin
Feature: fix for provider not being set on failed txs

  Scenario: user is trying to swap
    Given user is using a smart account on Polygon and trying to swap an ERC20 that needs an approval

    When user swaps
    Then the swap tx fails
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

#### Polygon, Smart Account, ERC20 Source token


https://github.com/user-attachments/assets/c95d838c-f688-403c-abf2-58f3ca74228b

<img width="1436" height="816" alt="Screenshot 2026-01-22 at 1 23 19 PM"
src="https://github.com/user-attachments/assets/576add03-9312-4cc5-9ff5-1661bc138237"
/>

### OP, Non smart account, non STX, ERC20 source token

Notice how the tx history is immediately populated with the swap details


https://github.com/user-attachments/assets/6de11569-736c-4d15-923d-9512df695b8a

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Improves history association and activity rendering for swaps/bridges.
> 
> - `useBridgeTxHistoryData`: adds lookup by `actionId` (in addition to
tx id and `originalTransactionId`); new tests cover actionId matching
and existing paths
> - `TransactionElement`: treats swaps with a matching history item as
unified, uses `getSwapBridgeTxActivityTitle` for titles, and routes
clicks through unified handler (eliminates transient "Swaps Transaction"
label)
> - `activity/index.ts`: tightens MetaMask Pay filtering for bridge
receives by ensuring `txMetaId` exists before matching required ids
> - Bumps deps: `@metamask/bridge-status-controller` to `^64.4.5` and
`@metamask/bridge-controller` to `^64.8.2`
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
408e330. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants